var Quintus = function (opts) {
    var Q = {}
    Q.options = {

    }
    if(opts){
        _(Q.options).extend(opts)
    }

    Q._normalizeArg = function (arg) {
        if(_.isString(arg)){
            arg = arg.replace(/\s+/g,'').split(',')
        }
        if(!_.isArray(arg)){
            arg = [arg]
        }
        return arg
    }
    Q.extend = function (obj) {
        _(Q).extend(obj)
        return Q
    }
    Q.include = function (mod) {
        _.each(Q._normalizeArg(mod),function (m) {
            m = Quintus[m]||m
            m(Q)
        })
        return Q
    }
    Q.gameLoop = function (callback) {
        Q.lastGameLoopFrame = new Date().getTime()
        Q.gameLoopCallbackWrapper = function (now) {
            Q.loop = requestAnimationFrame(Q.gameLoopCallbackWrapper)
            let dt = now-Q.lastGameLoopFrame
            if (dt>100){dt=100}
            callback.apply(Q,[dt/1000])
            Q.lastGameLoopFrame = now
        }

        requestAnimationFrame(Q.gameLoopCallbackWrapper)
    }
    Q.pauseGame = function () {
        if(Q.loop){
            cancelAnimationFrame(Q.loop)
        }
        Q.loop = null
    }
    Q.unpauseGame = function () {
        if(!Q.loop){
            Q.lastGameLoopFrame = new Date().getTime()
            Q.loop = requestAnimationFrame(Q.gameLoopCallbackWrapper)
        }
    }
    return Q
}
